#include <cstdio>
#include <algorithm>
using namespace std;

struct node {
	int a, b;
};

node list[1005];

bool cmp(node x, node y) {
	return x.b < y.b;
}

int main() {
	int n, ans = 0;
	int hand;
	scanf("%d %d", &n, &hand);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &list[i].a, &list[i].b);
	}
	sort(list + 1, list + n + 1, cmp);

	for (int i = 1; i <= n; ++i) {
		if (hand >= list[i].b) {
			++ans;
			hand += list[i].a;
		} else {
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}